<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2021/11/2
  Time: 13:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>供应商修改</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-offset-3 col-md-6">
            <div class="page-header">
                <h2>
                    <small>
                        修改供应商信息
                    </small>
                </h2>
            </div>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-offset-3 col-md-6">
            <form action="${pageContext.request.contextPath}/user/providerDo/modify?managerProCode=${provider.proCode}" method="post">
                <input type="hidden" id="proId" name="proId" value="${provider.id}">
                <div class="form-group">
                    <label for="proCode">供应商编码：</label>
                    <input type="text" name="proCode" id="proCode" value="${provider.proCode}" class="form-control" ${sessionScope.userSession.userRole == 1 ? "required":"disabled"}>
                    <span id="tipsProCode" style="color:red"></span>
                </div>
                <div class="form-group">
                    <label for="proName">供应商名称：</label>
                    <input type="text" name="proName" id="proName" value="${provider.proName}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="proContact">联系人：</label>
                    <input type="text" name="proContact" id="proContact" value="${provider.proContact}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="proPhone">联系电话：</label>
                    <input type="text" name="proPhone" id="proPhone" value="${provider.proPhone}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="proAddress">联系地址：</label>
                    <input type="text" name="proAddress" id="proAddress" value="${provider.proAddress}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="proFax">传真：</label>
                    <input type="text" name="proFax" id="proFax" value="${provider.proFax}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label for="proDesc">描述：</label>
                    <input type="text" name="proDesc" id="proDesc" value="${provider.proDesc}" class="form-control" required>
                </div>
                <div class="form-inline">
                    <div  class="col-md-offset-4">
                        <input type="submit" class="btn btn-default" value="&emsp;修改&emsp;" onclick="show()">
                        <button type="button" class="btn btn-default">
                            <a href="${pageContext.request.contextPath}/user/providerDo/providerPage">
                                &emsp;返回&emsp;
                            </a>
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<script src="${pageContext.request.contextPath}/webjars/jquery/3.6.0/jquery.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
        integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<script>
    let show = function () {
        console.log($('#id').val());
        console.log($('#proCode').val());
        console.log($('#proName').val());
        console.log($('#proContact').val());
        console.log($('#proPhone').val());
        console.log($('#proAddress').val());
        console.log($('#proFax').val());
        console.log($('#proDesc').val());
    }

    $(function () {
        $('#proCode').blur(function () {
            let proCode = $('#proCode').val();
            console.log(proCode);
            proCodeModifyCheck(proCode);
        });
    })

    //用户编码更新查重
    function proCodeModifyCheck(proCode) {
        $.ajax({
            url:"${pageContext.request.contextPath}/user/providerDo/checkProCode",
            type:"POST",
            data:{
                ProCode:proCode,
                OperationName:'administratorsModify',
                id:${provider.id}
            },
            success:function (data) {
                console.log(data);
                if(data !== 0){
                    $('#tipsProCode').text("*供应商编码重复")
                }else{
                    $('#tipsProCode').text("")
                }
            }
        })
    }

</script>

</body>
</html>

